//
//  HotCommentDataVC.m
//  AroundTheWorld
//
//  Created by dllo on 16/5/25.
//  Copyright © 2016年 IfelseGo an. All rights reserved.
//

#import "HotCommentDataVC.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height

@interface HotCommentDataVC ()

@end

@implementation HotCommentDataVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, -60, WIDTH, 120)];
    self.view.backgroundColor = [UIColor colorWithRed:53 / 255.0 green:176 /255.0 blue:131 / 255.0 alpha:1.0];
    [self.view addSubview:view];
    UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 60, WIDTH, HEIGHT - 60)];
    [webView setUserInteractionEnabled:YES];//是否支持交互
    [webView setOpaque:NO];//opaque是不透明的意思
    [webView setScalesPageToFit:YES];//自动缩放以适应屏幕
    [self.view addSubview:webView];
    NSString *string = self.myUrl;
    //加载网页的方式
    //1.创建并加载远程网页
    NSURL *url = [NSURL URLWithString:string];
    [webView loadRequest:[NSURLRequest requestWithURL:url]];
    
    
//    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH / 2 + 30, 30, 60, 24)];
//    label.text = @"楼主";
//    label.font = [UIFont systemFontOfSize:15];
//    label.layer.borderWidth = 2;
//    label.layer.borderColor = [[UIColor greenColor] CGColor];
//    label.textAlignment = NSTextAlignmentCenter;
//    [self.view addSubview:label];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(20, 25, 30, 30);
    button.backgroundColor = [UIColor clearColor];
    [button setImage:[[UIImage imageNamed:@"btn_mine_fanhui"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(buttonAtcion) forControlEvents:UIControlEventTouchUpInside];
    
    //收藏按钮
    self.scButton = [self addButton:@"btn_star0" rowRange:WIDTH - 105];
    self.fxButton = [self addButton:@"btn_fenxiang2" rowRange:WIDTH - 55];
    [self.fxButton addTarget:self action:@selector(fxButtonAction) forControlEvents:UIControlEventTouchUpInside];
    
   
    
    // Do any additional setup after loading the view.
}
- (void)buttonAtcion
{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

- (UIButton *)addButton:(NSString *)imageName rowRange:(NSInteger )rowNum
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(rowNum, 26, 25, 25);
    [button setBackgroundImage:[[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
    [self.view addSubview:button];
    return button;
}

//分享
- (void)fxButtonAction
{
    /**
     根据平台名，返回平台对象
     
     @param platformName sns平台名
     
     @return UMSocialSnsPlatform 平台对象
     */
    
    UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToSina];
    /**
     Sns平台类，用`platformName`作为标识，指定显示名称、显示的图片，点击之后的响应。
     */
    snsPlatform.displayName = @"新浪";
    snsPlatform.loginName = @"网易";
    
    UMSocialSnsPlatform *snsPlatform2 = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToTencent];
    snsPlatform2.displayName = @"腾讯微博";
    
    //分享第二步
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"558936d367e58eb81b001298"
                                      shareText:@"你要分享的文字"
                                     shareImage:[UIImage imageNamed:@"Icon-29.png"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToTencent,UMShareToRenren,nil]
                                       delegate:self];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
